package com.example.maruko_course_backend.aop;

import com.example.maruko_course_backend.utils.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

@Slf4j
public class ExceptionAdvice implements MethodInterceptor {
  public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    Object result = null;
    try {
      result = methodInvocation.proceed();
    } catch (Exception e) {
      log.error("Global Exception Catch: " + StringUtil.getExceptionStrMsg(e));
    }
    return result;
  }
}
